import UnRAR

# extract all the files in test.rar
UnRAR.Archive('test.rar').extract()

# extract all the files in test.rar matching the wildcard *.txt
UnRAR.Archive('test.rar').extract('*.txt')

# print the name and size of each file, extracting small ones
for fileInArchive in UnRAR.Archive('test.rar').iterfiles():
    print fileInArchive.filename, fileInArchive.size
    if fileInArchive.size <= 1024:
        fileInArchive.extract()

# print the contents of any file whose name ends with test.txt
for fileInArchive in UnRAR.Archive('test.rar').iterfiles():
    if fileInArchive.filename.endswith('test.txt'):
       print fileInArchive.open('rt').read()
